home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 10202 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.9 KB  |  77 lines

  1. Path: dispatch.news.demon.net!demon!harlquin.demon.co.uk
  2. From: vaughan@harlquin.demon.co.uk (vaughan edwards)
  3. Newsgroups: comp.lang.c++
  4. Subject: STL and sort
  5. Date: Wed, 06 Mar 1996 16:35:31 GMT
  6. Message-ID: <826130135.20401@harlquin.demon.co.uk>
  7. NNTP-Posting-Host: harlquin.demon.co.uk
  8. X-NNTP-Posting-Host: harlquin.demon.co.uk
  9. X-Newsreader: Forte Agent .99c/32.126
  10.  
  11. Being new to STL, I am working through some of the examples in the
  12. documentation.
  13.  
  14. Using GCC, all was fine until I attempted to sort a vector using the
  15. following code: 
  16.  
  17. //------------------
  18.  
  19. //misc code
  20.  
  21.  
  22. struct NameCompare {
  23.     bool operator()(const person& a, const person &b)
  24.         {return a.last_name < b.last_name;}
  25. }
  26.  
  27. NameCompare nameComp;
  28.  
  29. vector<person> roster;
  30.  
  31. // add persons
  32.  
  33. sort(roster.begin(), roster.end(),nameComp);
  34.  
  35. // etc
  36.  
  37. //----------------
  38.  
  39. this results in the following compiler errors
  40.  
  41. /usr/include/g++/algo.h: In function `void __quick_sort_loop(struct
  42. person *, struct person *, struct NameCompare)':
  43. /usr/include/g++/algo.h:746: call of overloaded `value_type' is
  44. ambiguous
  45. /usr/include/g++/vector.h:180: candidates are: value_type(person
  46. *const &)
  47. /usr/include/g++/iterator.h:90:                 value_type(const
  48. person *)
  49. /usr/include/g++/algo.h: In function `void
  50. __unguarded_insertion_sort(struct person *, struct person *, struct
  51. NameCompare)':
  52. /usr/include/g++/algo.h:834: call of overloaded `value_type' is
  53. ambiguous
  54. /usr/include/g++/vector.h:180: candidates are: value_type(person
  55. *const &)
  56. /usr/include/g++/iterator.h:90:                 value_type(const
  57. person *)
  58. /usr/include/g++/algo.h: In function `void __insertion_sort(struct
  59. person *, struct person *, struct NameCompare)':
  60. /usr/include/g++/algo.h:806: call of overloaded `value_type' is
  61. ambiguous
  62. /usr/include/g++/vector.h:180: candidates are: value_type(person
  63. *const &)
  64. /usr/include/g++/iterator.h:90:                 value_type(const
  65. person *)
  66.  
  67.  
  68. probably something simple - but I could do with some pointers
  69.  
  70.  
  71. TIA 
  72.  
  73. Vaughan
  74.  
  75.  
  76.  
  77.